<!DOCTYPE html>
<html>
<head>
<title>积分抽奖-奖项管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<#include "../../../../include/resources.html">
<script type="text/javascript">
    var dataGrid;
    var winWidth = 400;
    var winHeight = 350;
    var addTitle = "添加";
	var addUrl = "/modules/user/score/lottery/append.html";
	   
	var modifyTitle = "编辑";
    var modifyUrl =  "/modules/user/score/lottery/modify.html";
    var modifyWinParmeters = "'{0}','"+modifyTitle+"',920,650,'"+modifyUrl+"'";

    var disableUrl =  "/modules/user/score/lottery/disable.html";
    var enableUrl = "/modules/user/score/lottery/enable.html"; //启用窗口链接地址
	var txt1 = "禁用";
	var txt2 = "启用";
	var val1 = true;
	var val2 = false;
    
    $(function() {
        dataGrid = $('#dataGrid').datagrid({
            url : '/modules/user/score/lottery/list.html',
            fit : true,
            fitColumns : true,
            border : false,
            pagination : true,
            idField : 'id',
            pageSize : pageSize,
            pageNums : 1,
            pageList : pageList,
            sortName : 'id',
            sortOrder : 'asc',
            checkOnSelect : false,
            selectOnCheck : false,
            nowrap : false,
			singleSelect : true,
            columns:[[
                { field: 'id', title: '编号', width: 50, sortable:false },              
                { field: 'name', title: '名称', width: 180, sortable:false },
                { field: 'type', title: '类型', width: 150, sortable:false, 
            	  	formatter: function(value,row,index){
            	  		if(value==1){
            	  			return "积分";
            	  		}else if(value==2){
            	  			return "现金";
            	  		}
            		} 
                }, 
                { field: 'value', title: '中奖值', width: 100, sortable:false, 
            	  	formatter: function(value,row,index){
            	  		if(row.type==1){
            	  			return value+"积分";
            	  		}else{
            	  			return value+"元";
            	  		}
            		}  
                }, 
                { field: 'rate', title: '中奖率(%)', width: 90, sortable:false },  
                { field: 'addTime', title: '添加时间', width: 150, sortable:false, 
              	  	formatter: function(value,row,index){
              	  		return getLocalTime(value,4);
              		}
                }, 
                { field: 'status', title: '状态', width: 60, sortable:false, 
            	  	formatter: function(value,row,index){
            	  		if(value==1){
            	  			return "启用";
            	  		}else if(value==0){
            	  			return "未启用";
            	  		}
            		} 
                },
                { field : 'action',
                  	title : '操作',
                  	width : 75,
                  	fixed : true,
                  	formatter : function(value, row, index) {
						var status = row.status;
						var type = row.type;
						var str = '';
						str += '<dl>';
						str += '<dt><a href="javascript:void(0);" onclick="$.fn.dataGridOptions.editFun('+row.id+',modifyTitle,winWidth,winHeight,modifyUrl);" title="编辑名称">编辑</a><i class="iconfont">&#xe639;</i></dt>' ;
						str += '<dd>';
						if(row.status==1){
							str += '<a href="javascript:void(0);" onclick="$.fn.dataGridOptions.recordOptFun('+row.id+',disableUrl,txt1,val1);">禁用</a>';
						} else if(row.status==0){
							str += '<a href="javascript:void(0);" onclick="$.fn.dataGridOptions.recordOptFun('+row.id+',enableUrl,txt2,val2);">启用</a>';
						}
						str += '</dd></dl>'
						return str;
                  	}
                } 
            ] ],
            toolbar : '#toolbar',
            onLoadSuccess : function() {
                $('#searchForm table').show();
                parent.$.messager.progress('close');
            }
        });
    });
</script>
</head>
<body style="padding:0 20px;" >
	<div class="easyui-layout" data-options="fit : true,border : false">
        <div data-options="region:'north',border:false,collapsible:false" id="searchBox">
            <div class="sRight">
				<a onclick="$.fn.dataGridOptions.addFun(-1,addTitle,winWidth,winHeight,addUrl);" href="javascript:void(0);" class="addBtn"><i class="iconfont">&#xe629;</i>添加</a>
            </div>
        </div>
        <div data-options="region:'center'" style="margin-top:30px;padding-bottom:30px;">
            <table id="dataGrid"></table>
        </div>
    </div>
    <script src="${theme_dir}/js/search.js"></script>
</body>
</html>
